<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table{
            margin-top: 10px;
            border: 1px solid #000;
        }
        table td{
            border: 1px solid #000;
        }
    </style>
</head>
<body>
    <span>ID:</span><input type="text" id="uid">
    <span>姓名:</span><input type="text" id="uname">
    <span>电话:</span><input type="text" id="utel">
    <button id="btn">保存</button>
    <table>
        <thead>
            <tr>
                <td>ID</td>
                <td>姓名</td>
                <td>电话</td>
                <td>操作</td>
            </tr>
        </thead>
        <tbody></tbody>
    </table>
    <script>
        //  动态表格的创建, 在输入框中输入内容后,点击保存则在表格末尾添加一条记录, 
        // 点击删除则会删除对应行的记录
        var oId=document.querySelector("#uid");
        var oName=document.querySelector("#uname");
        var oTel=document.querySelector("#utel");
        var oBtn=document.querySelector("#btn");

        oBtn.onclick=function(){
            if(oId.value==""||oName.value==""||oTel.value==""){
                alert("您还有未填写的内容");
            }else{
                var tr=document.createElement("tr");
                var td1=document.createElement("td");
                var td2=document.createElement("td");
                var td3=document.createElement("td");

                td1.innerHTML=oId.value;
                td2.innerHTML=oName.value;
                td3.innerHTML=oTel.value;
                tr.appendChild(td1);
                tr.appendChild(td2);
                tr.appendChild(td3);
                tbody.appendChild(tr);
            }
        }


    </script>
</body>
</html>